﻿using VisualWip.Core;
using VisualWip.Core.Columns;
using VisualWip.Core.Interfaces;
using VisualWip.PresentationModel.WorkItem;
using VisualWip.TFS2010Common;

namespace VisualWip.TFS2010Providers
{
    public class TfsSingleWorkItemSettingsViewModel : SingleWorkItemSettingsViewModel
    {
        public TfsSingleWorkItemSettingsViewModel(Application application, SingleWorkItemColumn column,
                                                  IWorkItemSizeProvider workItemSizeProvider,
                                                  IColumnTypeProvider columnTypeProvider)
            : base(application, column, workItemSizeProvider, columnTypeProvider)
        {
            Init();
        }

        private void Init()
        {
            var connection = new TfsConnection();
            connection.Connect();
            Column.Query = new WorkItemIdQuery(connection) {QueryText = string.Empty};
        }


        public override string WorkItemId
        {
            get { return Column.Query.QueryText; }
            set
            {
                if (value != Column.Query.QueryText)
                {
                    Column.Query.QueryText = value;
                    OnPropertyChanged(this,()=> WorkItemId);
                }
            }
        }
    }
}